package com.itheima.stargraph.utils;

import com.itheima.stargraph.pojo.User;

/**
 * ThreadLocal工具类
 *
 * @Author mr.wu
 * @Date 2025-6-9 14:40
 */
public class UserThreadlocalUtils {

    private static ThreadLocal<User> userThreadLocal = new ThreadLocal<>();

    /**
     * 设置用户
     * @param user
     */
    public static void setUser(User user) {
        userThreadLocal.set(user);
    }

    /**
     * 获取用户
     * @return
     */
    public static User getUser() {
        return userThreadLocal.get();
    }

    /**
     * 清理内存
     */
    public static void remove() {
        userThreadLocal.remove();
    }
}
